﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GrandMan.GMDataSetTableAdapters;

namespace GrandMan.Models
{
    public class BaseModel
    {
        static BaseModel()
        {
            var context = ContextMgt.GetInstance();
            new BaseDataTableAdapter().Fill(context.BaseData);
            var company = (from p in context.BaseData
                        where p.Name == "Company"
                        select p).SingleOrDefault();
            if (company == null|| company.IsValueNull())
                SCompany = string.Empty;
            else
                SCompany = company.Value;

            var address = (from p in context.BaseData
                           where p.Name == "Address"
                           select p).SingleOrDefault();
            if (address == null || address.IsValueNull())
                SAddress = string.Empty;
            else
                SAddress = address.Value;

            var phone = (from p in context.BaseData
                           where p.Name == "Phone"
                           select p).SingleOrDefault();
            if (phone == null || phone.IsValueNull())
                SPhone = string.Empty;
            else
                SPhone = phone.Value;
        }

        public string Company { get { return SCompany; } }
        public string Phone { get { return SPhone; } }
        public string Address { get { return SAddress; } }

        public static string SCompany { get; set; }
        public static string SPhone { get; set; }
        public static string SAddress { get; set; }
    }
}